home *** CD-ROM | disk | FTP | other *** search
/ PC Direct 1998 August / PC Direct August 1998.iso / S / powerj / Product / hpp.z / WFORM.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-25  |  14.8 KB  |  477 lines

  1. /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2.    %     Copyright (C) 1994, by WATCOM International Inc.  All rights    %
  3.    %     reserved.  No part of this software may be reproduced or        %
  4.    %     used in any form or by any means - graphic, electronic or       %
  5.    %     mechanical, including photocopying, recording, taping or        %
  6.    %     information storage and retrieval systems - except with the     %
  7.    %     written permission of WATCOM International Inc.                 %
  8.    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. */
  10.  
  11. /*************************************************************************
  12.  *
  13.  * WForm -- Base Form class
  14.  *
  15.  *
  16.  *   Events:
  17.  *
  18.  *       Close --
  19.  *
  20.  *       InitMenu --
  21.  *
  22.  *       QueryClose --
  23.  *
  24.  *************************************************************************/
  25.  
  26. #ifndef _WFORM_HPP_INCLUDED
  27. #define _WFORM_HPP_INCLUDED
  28.  
  29. #ifndef _WNO_PRAGMA_PUSH
  30. #pragma pack(push,8);
  31. #pragma enum int;
  32. #endif
  33.  
  34. #ifndef _WVECTOR_HPP_INCLUDED
  35. #  include "wvector.hpp"
  36. #endif
  37. #ifndef _WWINDOW_HPP_INCLUDED
  38. #  include "wwindow.hpp"
  39. #endif
  40. #ifndef _WCONTROL_HPP_INCLUDED
  41. #  include "wcontrol.hpp"
  42. #endif
  43. #ifndef _WPOPMENU_HPP_INCLUDED
  44. #  include "wpopmenu.hpp"
  45. #endif
  46. #ifndef _WFILPATH_HPP_INCLUDED
  47. #  include "wfilpath.hpp"
  48. #endif
  49.  
  50.  
  51. extern template WVector<WWindow>;
  52. extern template WVector<WObject>;
  53. extern template WVector<WString>;
  54.  
  55. class WAcceleratorTable;
  56. class WStatusBar;
  57.  
  58. enum WWindowState {
  59.     WWindowStateNormal,
  60.     WWindowStateMinimized,
  61.     WWindowStateMaximized
  62. };
  63.  
  64. //
  65. // Styles
  66. //
  67.  
  68. #define WFormDefault ((WStyle)0x12CF0000L) // WS_OVERLAPPEDWINDOW|WS_VISIBLE|WS_CLIPCHILDREN
  69.  
  70. class WCMCLASS WForm : public WWindow {
  71.     WDeclareSubclass( WForm, WWindow );
  72.  
  73.     public:
  74.  
  75.         /**************************************************************
  76.          * Constructors
  77.          **************************************************************/
  78.  
  79.         WForm();
  80.     
  81.         WForm( WWindow * parent, WWindowHandle hdl );
  82.     
  83.         virtual ~WForm();
  84.  
  85.         /**************************************************************
  86.          * Properties
  87.          **************************************************************/
  88.  
  89.         // AcceleratorTable
  90.  
  91.         WAcceleratorTable GetAcceleratorTable() const;
  92.         WBool SetAcceleratorTable( const WAcceleratorTable & table,
  93.                                    WBool append=FALSE );
  94.  
  95.         // Active
  96.         //
  97.         //     If TRUE, window is the active window for this thread.
  98.         //     Use the Activate method to force a window to become
  99.         //     the active window.
  100.  
  101.         virtual WBool GetActive() const;
  102.  
  103.         // AutomaticScrolling
  104.  
  105.         WBool GetAutomaticScrolling() const;
  106.         WBool SetAutomaticScrolling( WBool automaticScrolling );
  107.  
  108.         // ClientWindow
  109.         //
  110.         //      The client window will automatically be positioned directly
  111.         //      over the client area of the form, excluding any space taken
  112.         //      up by docked windows such as toolbars and status bars.
  113.  
  114.         virtual WWindow * GetClientWindow();
  115.         virtual WBool SetClientWindow( WWindow * clientWindow );
  116.  
  117.         // ControlCount
  118.  
  119.         virtual WInt GetControlCount();
  120.  
  121.         // MaximizedPosition
  122.         //
  123.         //    Defines the left & top position of the form when
  124.         //    maximized.
  125.  
  126.         WPoint GetMaximizedPosition() const;
  127.         WBool  SetMaximizedPosition( const WPoint & maxPos );
  128.  
  129.         // MaximizedSize
  130.         //
  131.         //    Defines the height & width of the form when
  132.         //    maximized.
  133.  
  134.         WSize  GetMaximizedSize() const;
  135.         WBool  SetMaximizedSize( const WSize & maxSize );
  136.  
  137.         // MaximumTrackingSize
  138.         //
  139.         //    Defines the maximum height & width when the window
  140.         //    is being resized.
  141.  
  142.         WSize GetMaximumTrackingSize() const;
  143.         WBool SetMaximumTrackingSize( const WSize & maxTrackSize );
  144.  
  145.         // Menu
  146.  
  147.         virtual WMenu *GetMenu() const;
  148.         virtual WBool  SetMenu( WMenu *menu );
  149.  
  150.         // MinimumTrackingSize
  151.         //
  152.         //    Defines the minimum height & width when the window
  153.         //    is being resized.
  154.  
  155.         WSize GetMinimumTrackingSize() const;
  156.         WBool SetMinimumTrackingSize( const WSize & minTrackSize );
  157.  
  158.         // SystemMenu
  159.         //
  160.         //
  161.  
  162.         WSystemMenu *GetSystemMenu();
  163.  
  164.         // Icon in the window's title bar
  165.         //
  166.         //
  167.  
  168.         WIcon GetIcon(WBool size = FALSE);
  169.         WIcon SetIcon(const WIcon & icon, WBool size = FALSE); // default small size
  170.  
  171.         // HelpFile
  172.  
  173.         WFilePath GetHelpFile() const;
  174.         WBool     SetHelpFile( const WFilePath & helpFile );
  175.  
  176.         // HintText
  177.  
  178.         WString       GetHintText() const;
  179.         virtual WBool SetHintText( const WString & str );
  180.  
  181.         // StatusBar
  182.  
  183.         virtual WStatusBar *GetStatusBar() const;
  184.         virtual WBool       SetStatusBar( WStatusBar * statusBar );
  185.  
  186.         // VirtualClientRectangle
  187.  
  188.         virtual WBool SetVirtualClientRectangle( const WRect & rect );
  189.         virtual WRect GetVirtualClientRectangle() const;
  190.  
  191.         // WindowID
  192.  
  193.         virtual WUInt GetWindowID() const;
  194.         virtual WBool SetWindowID( WUInt newID );
  195.  
  196.         // WindowState
  197.         
  198.         WWindowState GetWindowState();
  199.         WBool        SetWindowState( WWindowState state );
  200.  
  201.         /**************************************************************
  202.          * Methods
  203.          **************************************************************/
  204.  
  205.         // Activate
  206.         //
  207.         //     Force this form to become the active window for the
  208.         //     thread.
  209.  
  210.         virtual WBool Activate() const;
  211.  
  212.         // AddDockedWindow
  213.  
  214.         virtual void AddDockedWindow( WWindow * docked,
  215.                                       WWindow * sibling=NULL,
  216.                                       WBool insertBeforeSibling=TRUE );
  217.  
  218.         // AddObject
  219.  
  220.         WBool AddObject( WObject * object, const WString & objectName );
  221.  
  222.         // Close
  223.  
  224.         virtual WBool Close();
  225.  
  226.         // FindObject
  227.  
  228.         WObject *FindObject( const WString & objectName,
  229.                              WBool recurseUp=TRUE, WClassID id=0 );
  230.  
  231.         // RemoveObject
  232.  
  233.         WBool RemoveObject( WObject * object, WBool recurseUp=TRUE );
  234.         WBool RemoveObject( const WString & objectName,
  235.                             WBool recurseUp=TRUE, WClassID id=0 );
  236.  
  237.         // AddDrawPrimitive
  238.         //
  239.         // Note: The added drawPrimitives will automatically be
  240.         //       deleted by the window in its destructor, so the
  241.         //       user should NOT delete this primitives him/herself
  242.  
  243.         virtual void AddDrawPrimitive( WDrawPrimitive * drawPrimitive );
  244.  
  245.         // AddPinnedWindow
  246.  
  247.         virtual WBool AddPinnedWindow( WWindow * pinned );
  248.  
  249.         // AdjustClientRectangle
  250.  
  251.         virtual void AdjustClientRectangle( WRect & rect,
  252.                                             WBool moveChildren=FALSE );
  253.  
  254.         // Center
  255.         //
  256.         //    Center the form, either over its parent (owner) or
  257.         //    over an arbitrary window.  Pass NULL to center over
  258.         //    the desktop.
  259.  
  260.         WBool Center();
  261.         WBool Center( WWindow *window );
  262.  
  263.         // ClearMenu
  264.  
  265.         WMenu * ClearMenu();
  266.  
  267.         // CreateStatusBar
  268.  
  269.         WBool CreateStatusBar();
  270.  
  271.         // FDXInitializeControls
  272.         //
  273.         //      Called by the default Initialize event handler
  274.  
  275.         virtual WBool FDXInitializeControls();
  276.  
  277.         // FDXUpdateControls
  278.         //
  279.         //      Called by the default OK event handler
  280.  
  281.         virtual WBool FDXUpdateControls();
  282.  
  283.         // Initialize
  284.  
  285.         virtual WBool Initialize();
  286.  
  287.         // RedrawFrame
  288.  
  289.         WBool RedrawFrame();
  290.  
  291.         // RemoveDockedWindow
  292.  
  293.         virtual void RemoveDockedWindow( WWindow * docked );
  294.  
  295.         // RemoveDrawPrimitive
  296.         //
  297.         // Note: The added drawPrimitives will automatically be
  298.         //       deleted by the window in its destructor, so the
  299.         //       user should NOT delete this primitives him/herself
  300.  
  301.         virtual void RemoveDrawPrimitive( WDrawPrimitive * drawPrimitive );
  302.  
  303.         // RemovePinnedWindow
  304.  
  305.         virtual WBool RemovePinnedWindow( WWindow *pinned );
  306.  
  307.         // ResetSystemMenu
  308.  
  309.         WBool ResetSystemMenu();
  310.  
  311.         // ShiftDockedWindows
  312.  
  313.         virtual void ShiftDockedWindows( WDockPosition pos,
  314.                                          WInt startIndex, WInt endIndex,
  315.                                          WBool moveUp );
  316.  
  317.         // Show
  318.  
  319.         virtual WBool Show( WShowStyle style=WWinStateShowNormal );
  320.     
  321.         // UpdateMenu
  322.  
  323.         WBool UpdateMenu();
  324.  
  325.         /**************************************************************
  326.          * Item properties
  327.          **************************************************************/
  328.  
  329.         // Control
  330.  
  331.         virtual WControl * GetControl( WInt itemNumber );
  332.  
  333.         // DockedWindow
  334.  
  335.         virtual WWindow * GetDockedWindow( WInt index, WDockPosition pos );
  336.  
  337.         // DockedWindowCount
  338.  
  339.         virtual WInt GetDockedWindowCount( WDockPosition pos );
  340.  
  341.         /**************************************************************
  342.          * Event handlers
  343.          **************************************************************/
  344.  
  345.         WBool InitMenuEventHandler( WForm * form,
  346.                                     WMessageEventData * event );
  347.  
  348.         WBool SystemCommandEventHandler( WForm * form,
  349.                                          WMessageEventData * event );
  350.  
  351.         WBool CommandEventHandler( WForm * form,
  352.                                    WMessageEventData * event );
  353.  
  354.         WBool InitPopupMenuEventHandler( WForm * form,
  355.                                          WMessageEventData * event );
  356.  
  357.         WBool MenuSelectEventHandler( WForm * form,
  358.                                       WMessageEventData * event );
  359.  
  360.         WBool FormCloseEventHandler( WForm * form,
  361.                                              WEventData * event );
  362.                                              
  363.         WBool EraseBackgroundHandler( WWindow * window,
  364.                                       WPaintEventData * event );
  365.  
  366.         WBool ResizeEventHandler( WWindow * window,
  367.                                   WResizeEventData * event );
  368.  
  369.         WBool DestroyEventHandler( WWindow * window, WEventData * event );
  370.  
  371.         WBool HelpEventHandler( WWindow * window, WHelpEventData * event );
  372.  
  373.         WBool PositionChangedEventHandler( WForm *window,
  374.                                            WResizeEventData * event );
  375.  
  376.         WBool ScrollEventHandler( WWindow * window,
  377.                                   WScrollBarEventData * event );
  378.  
  379.         /**************************************************************
  380.          * Overrides
  381.          **************************************************************/
  382.         
  383.         virtual WBool SetPopup( WPopupMenu * popup );
  384.  
  385.         virtual WBool AdjustFloatingFormStyle( WStyle & style,
  386.                                                WStyle & exStyle );
  387.  
  388.         virtual WRect CalculateSize( const WRect &, WBool adjust );
  389.  
  390.         virtual void SetDockedPosition( WDockPosition pos, WInt index=0,
  391.                                         WBool insert=FALSE,
  392.                                         WWindow * sibling=NULL,
  393.                                         WBool insertBeforeSibling=TRUE,
  394.                                         WBool callEventHandler=TRUE );
  395.  
  396.         virtual void AddControl( WControl * ctrl );
  397.  
  398.         virtual void RemoveControl( WControl * ctrl );
  399.  
  400.         virtual WBool ProcessMessage( const WMessage & msg, WLong & returns );
  401.  
  402.         virtual WBool SetFont( const WFont & font, WBool preserveSize=TRUE );
  403.  
  404.         virtual WFont GetFont( WBool getResultingFont=TRUE );
  405.  
  406.         virtual WUInt AssignWindowID();
  407.  
  408.         virtual WStyle GetDefaultStyle() const;
  409.  
  410.         virtual WStyle GetDefaultExtendedStyle() const;
  411.     
  412.         virtual WBool LoadWindow( WWindow * parent,
  413.                                   const WResourceID & id,
  414.                                   WModuleHandle module=_ApplicationModule );
  415.     
  416.         virtual WBool MakeWindow( WWindow * parent, WUInt id,
  417.                                   const WChar *className,
  418.                                   const WChar *title, const WRect & r,
  419.                                   WStyle wstyle, WStyle exStyle,
  420.                                   void * data=NULL );
  421.  
  422.         virtual WBool CloneWindow( WStyle newStyle, WStyle newExStyle,
  423.                                    void * data=NULL );
  424.  
  425.         /**************************************************************
  426.          * Others
  427.          **************************************************************/
  428.         
  429.         virtual WBool FilterMessage( WMessage & msg, WBool & eatMessage );
  430.  
  431.         WBool SetInResize( WBool inResize ) { _inResize = inResize; return( TRUE ); };
  432.         WBool GetInResize() const { return( _inResize ); };
  433.  
  434.         WRect GetLastResizeRect() const { return( _lastResizeRect ); };
  435.  
  436.         /**************************************************************
  437.          * Data members
  438.          **************************************************************/
  439.  
  440.     protected:
  441.  
  442.         WRect                           _lastResizeRect;
  443.  
  444.     private:
  445.  
  446.         WString                         _hintText;
  447.         WFilePath                       _helpFile;
  448.         WStatusBar *                    _statusBar;
  449.         WMenu *                         _menu;
  450.         WSystemMenu *                   _systemMenu;
  451.         WInt                            _nextChildID;
  452.         WAcceleratorTable *             _accelTable;
  453.         WSize                           _maxSize;
  454.         WPoint                          _maxPosition;
  455.         WSize                           _minTrackSize;
  456.         WSize                           _maxTrackSize;
  457.         WWindow *                       _clientWindow;
  458.         WStyle *                        _dockStyle;
  459.         WStyle *                        _dockExStyle;
  460.         WDrawPrimitiveGroup *           _drawPrimitives;
  461.         WVector< WWindow > *            _dockedWindows;
  462.         WVector< WWindow > *            _dockWindowFrames;
  463.         WVector< WWindow > *            _pinnedWindows;
  464.         WVector< WObject > *            _objects;
  465.         WVector< WString > *            _objectNames;
  466.         WRect                           _virtClientRect;
  467.         WBool                           _automaticScrolling;
  468.         WBool                           _inResize;
  469. };
  470.  
  471. #ifndef _WNO_PRAGMA_PUSH
  472. #pragma enum pop;
  473. #pragma pack(pop);
  474. #endif
  475.  
  476. #endif // _WFORM_HPP_INCLUDED
  477.